﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MediatR;
using W.Device.Domain;
using W.Device.API.Application.Command;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.AspNetCore.Authorization;
namespace W.Device.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class DeviceController : ControllerBase
    {
        private readonly IMediator mediator;

        public DeviceController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 设备添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns>返回影响行数</returns>
        [HttpPost]
        public async Task<int> DeviceAdd(DeviceAddCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 设备修改
        /// </summary>
        /// <param name="command"></param>
        /// <returns>返回影响行数</returns>
        [HttpPost]
        public async Task<int> DeviceUpdate(DeviceUpdateCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 设备反填
        /// </summary>
        /// <param name="command"></param>
        /// <returns>返回集合</returns>
        [HttpPost]
        public async Task<List<DevicesInfo>> DeviceFan(DeviceFanCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 设备删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns>返回影响行数</returns>
        [HttpPost]
        public async Task<int> DeviceDelete(DeviceDeleteCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 设备批量删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns>返回影响行数</returns>
        [HttpPost]
        public async Task<int> DeviceDeleteAll(DeviceIsdelAllcommand allcommand)
        {
            return await mediator.Send(allcommand);
        }
        /// <summary>
        /// 设备批量修改
        /// </summary>
        /// <param name="command"></param>
        /// <returns>返回影响行数</returns>
        [HttpPost]
        public async Task<int> DeviceUpdateAll(DeviceUpdateAllCommand allcommand)
        {
            return await mediator.Send(allcommand);
        }
    }
}
